
import { createSlice } from '@reduxjs/toolkit';

export const DARK: string = 'dark' as const
export const LIGHT: string = 'light' as const


export interface themeOptionType {
    mainTheme: typeof DARK | typeof LIGHT;
}

const initialState: themeOptionType = {
    mainTheme: DARK
}

export const theme = createSlice({
    name: 'theme',
    initialState,
    reducers: {
        changeTheme(state) {
            if (state.mainTheme === DARK)
                state.mainTheme = LIGHT
            else if (state.mainTheme === LIGHT)
                state.mainTheme = DARK
        }
    }
})

export const { changeTheme } = theme.actions

export default theme.reducer